// import { baseUrl, khglUrl, dicUrl } from '@/config/env';
import request from '@/router/axios';
// import { userInfo, tableData } from '@/mock/user';
// import { menu, menuAll } from '@/mock/menu';
export const loginByUsername = (username, password, code, randomStr) => {
  var grant_type = 'password';
  var scope = 'server';
  return request({
    url: '/auth/oauth/token',
    headers: {
      'Authorization': 'Basic ZGdjbG91ZDpkZ2Nsb3Vk' // 此处为base64编码后的 dgcloud:dgcloud
      // 'Authorization': 'Basic ZmFjZSUzQWZhY2U=' // 此处为base64编码后的 desktop:desktop
    },
    method: 'post',
    params: { username, password, randomStr, code, grant_type, scope }
  });
};

export function mobileLogin(mobile, code) {
  var grant_type = 'mobile';
  var scope = 'server';
  return request({
    url: '/auth/mobile/token',
    headers: {
      'Authorization': 'Basic ZGdjbG91ZDpkZ2Nsb3Vk' // 此处为base64编码后的 dgcloud:dgcloud
      // 'Authorization': 'Basic ZmFjZSUzQWZhY2U=' // 此处为base64编码后的 desktop:desktop
    },
    method: 'post',
    params: { mobile, code, grant_type, scope }
  });
}

export const getUserInfo = () => {
  return request({
    // url: '/admin/user/info',
    url: '/clientauth/user/info',
    method: 'get'
  });
};

export const logout = (accesstoken, refreshToken) => {
  return request({
    url: '/auth/authentication/removeToken',
    method: 'post',
    params: { accesstoken, refreshToken }
  });
};
